package com.shengyuan.manage_os.old.ying.erpm;

import java.util.ArrayList;
import java.util.List;

import com.shengyuan.manage_os.old.ying.boce.jsy.AdminPicHandlerTask;
import com.shengyuan.manage_os.R;
import com.shengyuan.manage_os.old.ying.erpm.data.MenuItem;
import com.shengyuan.manage_os.old.ying.erpm.db.DBHelper;
import com.shengyuan.manage_os.old.ying.erpm.layout.Workspace.OnViewChangedListener;
import com.shengyuan.manage_os.old.ying.erpm.util.Utility;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Handler;
import android.os.Message;

public class NetActivity extends WorkSpaceActivity implements OnViewChangedListener {

	@Override
	public List<MenuItem> LoadMenuListItems() 
    {
    	MenuItem item;
    	List<MenuItem> list = new ArrayList<MenuItem>();
    	Resources res =getResources();
    	String[] city=res.getStringArray(R.array.main_menus_net);
    	for (int i = 0; i < city.length; i++) {
    		item = new MenuItem();
			item.title = city[i];
			item.index = i;
			list.add( item);
		} 
    	return list;
    }

    private Handler mHandler= new Handler(){

		@Override
		public void handleMessage(Message msg) {
			//BaseActivity.A_GONGCHENGMINGCHENG = Submit_System_Setting_Data_Task.A_GONGCHENGMINGCHENG_OA;
			//BaseActivity.A_GONGCHENGMINGCHENG_XIANGMU = Submit_System_Setting_Data_Task.A_GONGCHENGMINGCHENG_OA_XIANGMU;
			Intent intent = new Intent();
            switch (msg.arg1) {
            case 0:
            	AdminPicHandlerTask task = new AdminPicHandlerTask();
            	task.start();
            	return;
            case 1:
            	String oldPath, newPath;
            	oldPath = "/data/data/com.ying.erpm/databases/"+ DBHelper.DATABASE_NAME;
            	newPath = MainApplication.UploadPath +DBHelper.DATABASE_NAME;
            	//FileHelper.copyFile(oldPath, newPath);
            	if (Utility.copyFile(oldPath, newPath)) {
            		Utility.MessageBox("复制成功->" + newPath);
				}
            	return;
            }
            startActivity(intent);
		}
    	
    };
    @Override
	public boolean IsAllow() {
		if (LoginActivity.pmUser.getLogOut() == false) {
			return LoginActivity.pmUser.JiaoSe.contains("超级管理员");

		}
		else return false;
		}

	@Override
	public Handler GetHandler() {
		return mHandler;
	}	
}